﻿package {
	import flash.display.MovieClip;
	import flash.events.KeyboardEvent;
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	import flash.ui.Keyboard;
	
	public class test extends MovieClip{
		public var NPC:NPC1 = new NPC1();//修改
		public var m_akeys:int;
		public var myTimer:Timer = new Timer(100,0);
		
		public function test() {
			 //constructor code
			this.addChild(NPC);
			this.stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyboardDown);
			this.stage.addEventListener(KeyboardEvent.KEY_UP,onKeyboardUp);
			myTimer.addEventListener(TimerEvent.TIMER,timerHandle);
			myTimer.start();
		}
		
		public function onKeyboardDown(e:KeyboardEvent):void
		{
					m_akeys= e.keyCode;
		 }
		  
		public function onKeyboardUp(e:KeyboardEvent):void
		{
					m_akeys = -1;
		}
			
		public function timerHandle(e:TimerEvent):void
		{
			NPC.Input(m_akeys);
			NPC.NPCLogic();
		}

	}
	
}
